﻿@using Volo.Abp.Domain.Repositories
﻿@using Volo.Abp.Ui.Branding
@using YAPACS.BusinessObjects.Managements.Devices
@using YAPACS.BusinessObjects.Services
@using YAPACS.Organizations

@inject IBrandingProvider BrandingProvider
@inject IStationCodeProvider StationCodeProvider

@inject IRepository<Station, Guid> StationRepository
@inject IRepository<Department, Guid> DepartmentRepository
@inject ICurrentUserOrganization CurrentUserOrganization

@{
    Station station = null;
    Department department = null;

    var stationCode = StationCodeProvider.GetStationCode();

    if (!string.IsNullOrWhiteSpace(stationCode))
    {
        station = await StationRepository.GetAsync(x => x.Code == stationCode);
    }
    else
    {
        department = await DepartmentRepository.GetAsync(x => x.Id == CurrentUserOrganization.DepartmentId);
    }
}

<a class="navbar-brand" href="~/">
    @(BrandingProvider.AppName) - @(station?.Room.Name ?? department.Name)
</a>